package com.itheima.functioninterface;

import java.util.function.Function;

/**
 * <h1>ysm</h1>
 *
 * @author <a href="11n_yd2h5e1jx8@dingtalk.com">叶世铭</a>
 * @since 2024/1/29
 */
public class FunctionDemo {
    public static void main(String[] args) {
        System.out.println(calculate(new Function<String, Integer>() {
            @Override
            public Integer apply(String s) {
                return  Integer.parseInt(s);
            }
        }));
        System.out.println(calculate( s-> Integer.parseInt(s)));

        System.out.println(calculate1(s-> Integer.parseInt(s), i -> i +5));
    }

    public static int calculate(Function<String,Integer> function) {
        Integer value = function.apply("10");
        return value + 5;
    }
    public static int calculate1(Function<String,Integer> f1,Function<Integer,Integer> f2) {
        Integer value2 = f1.andThen(f2).apply("10");
        return value2;
    }
}
